
const BASE_URL="https://tea.qingnian8.com/api/bizhi"

export function request(config={}){
	
	let {url,
	method="GET",
	header={},
	data={}
	
	}= config
	url=BASE_URL+url;
	header['access-key']="mgs823@@"
	return new Promise((resolve,reject)=>{
		
		
	uni.request({
		url,
		data,
		method,
		header,
		success(res){
		if(res.data.errCode===0){
			
			resolve(res.data)//request函数返回这个res值
		}else if(res.data.errCode===400){
			uni.showModal({
				title:"网络请求错误400",
				content:res.data.errMsg
			})
			reject(res.data)
		}else{
			
			uni.showModal({
				title:"网络请求错误",
				content:res.data.errMsg
			})
			reject(res.data)
			
		}
		
		
		},
		fail(res){
			
			reject(res)
		}
		
	})	
		
	})
	

	
}


